﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public class DocClsScore
    {
        private readonly DAL.DocClsScore dal = new DAL.DocClsScore();
        public DocClsScore()
        { }


                /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(List<ElingOA6_Admin_DSJCJ.Model.DocClsScore> list)
        {
            dal.Update(list);
        }
        /// <summary>
        /// 获取信息考核分定义列表
        /// </summary>
        /// <param name="strWhere">查询条件</param>
        /// <returns>数据列表</returns>
        public DataSet GetDocClsScoreList(string strWhere)
        {
            return dal.GetDocClsScoreList(strWhere);
        }


        public DataSet ExecSql()
        {
            return dal.ExecSql();
        }

        /// <summary>
        /// 获取所有的年份，按年份降序
        /// <creator>sunlj</creator>
        /// <date>2013-10-16</date>
        /// </summary>
        /// <param name="strEntityNo"></param>
        /// <returns></returns>
        public DataSet getYears(string strEntityNo)
        {
            return dal.getYears(strEntityNo);
        }

        public void ExecPro(string EntityNo, int year)
        {
            dal.ExecPro(EntityNo, year);
        }

        /// <summary>
        /// 根据年份获取所有需要考核的信息考核分定义
        /// </summary>
        /// <param name="strEntityNo"></param>
        /// <param name="decYear"></param>
        /// <returns></returns>
        public List<Model.DocClsScore> getListByYearAndIsScore(string strEntityNo, decimal decYear)
        {
            DataSet ds = dal.getListByYearAndIsScore(strEntityNo, decYear);
            return DataTableToList(ds.Tables[0]);

        }
        /// <summary>
        /// 获取最大的年数
        /// <creator>wangl</creator>
        /// <date>2013-11-12</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <returns></returns>
        public int GetMaxYear(string entityNo)
        {
            return dal.GetMaxYear(entityNo);
        }
        /// <summary>
        /// 年度结转
        /// <creator>wangl</creator>
        /// <date>2013-11-12</date>
        /// </summary>
        /// <param name="entityNo"></param>
        /// <param name="year"></param>
        /// <returns></returns>
        public int YearTurn(string entityNo, decimal year)
        {
            return dal.YearTurn(entityNo, year);
        }
        /// <summary>
        /// 年度反结转
        /// <creator>wangl</creator>
        /// <date>2013-11-12</date>
        /// </summary>
        /// <param name="year"></param>
        /// <param name="FStatus"></param>
        /// <returns></returns>
        public int YearTurnChange(string entityNo, decimal year)
        {
            return dal.YearTurnChange(entityNo, year);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.DocClsScore> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.DocClsScore> modelList = new List<ElingOA6_Admin_DSJCJ.Model.DocClsScore>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.DocClsScore model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }
    }
}
